﻿using Common;
using System.Collections.Generic;
using T68Control.S12L_M1;

namespace T68Control.ViewModel
{
    public class ImagePopupViewModel : NotifyBase
    {
        private HomeViewModel homeViewModel = new HomeViewModel("123");
        public CommandBase UpCommand { get; set; }
        public CommandBase DownCommand { get; set; }
        private int number = 0;
        private int counts;
        private List<string> Images = new List<string>();

        public ImagePopupViewModel()
        { }

        public ImagePopupViewModel(List<string> imagePaths)
        {
            UpCommand = new CommandBase(UpEvent);
            DownCommand = new CommandBase(DownEvent);
            Images = imagePaths;
            counts = imagePaths.Count;
            CurrentImage = $"第{number + 1}张,共{counts}张";
            VisionMasterHelper.ExecVisionImageFlow(Images[number]);
        }

        private void UpEvent(object obj)
        {
            if (number > 0)
            {
                number--;
            }
            Up();
        }

        private void DownEvent(object obj)
        {
            if (number < counts - 1)
            {
                number++;
            }
            Down();
        }

        private void Up()
        {
            CurrentImage = $"第{number + 1}张,共{counts}张";
            VisionMasterHelper.ExecVisionImageFlow(Images[number]);
        }

        private void Down()
        {
            CurrentImage = $"第{number + 1}张,共{counts}张";
            VisionMasterHelper.ExecVisionImageFlow(Images[number]);
        }

        private string _currentImage;

        public string CurrentImage
        {
            get { return _currentImage; }
            set
            {
                _currentImage = value;
                this.DoNotify();
            }
        }
    }
}